package com.chris.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpSession;

/**
 * ͳһ�����ַ�
 * 
 * @author Administrator
 *
 */
public class CharsetEncodingFilter implements Filter {

	private String encoding;
	private HttpSession session;

	public void destroy() {
	}

	public void doFilter(ServletRequest servletRequest,
			ServletResponse servletResponse, FilterChain filterChain)
			throws IOException, ServletException {
		// System.out.println("init_doFilter=========");
		// RedisDao.getInstance().set("a", "abc");
		// System.out.println(RedisDao.getInstance().get("a"));
		// session = servletRequest.get
		servletRequest.setCharacterEncoding("utf-8");
		filterChain.doFilter(servletRequest, servletResponse);
	}

	public void init(FilterConfig filterConfig) throws ServletException {
		System.out.println("init_one=========");
		// ȡ�ó�ʼ������
		this.encoding = filterConfig.getInitParameter("encoding");
	}
}
